package com.hackvan2012.controllers.ajax;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hackvan2012.datastore.AppDatastore;

public class VoteController extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		AppDatastore ds = new AppDatastore();
		String from = req.getParameter("from");

		String entryId = req.getParameter("entryId");
		long vote = ds.castVote(entryId);
		if (vote < 0) {

		} else {
			try {
				resp.setContentType("text/xml; charset=UTF-8");
				resp.getWriter().write(""+vote);
			} catch (IOException e) {
				e.printStackTrace();
			}

		}
	}
}
